#include "dialogcalibrationsettings.h"
#include "ui_dialogcalibrationsettings.h"

DialogCalibrationSettings::DialogCalibrationSettings(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DialogCalibrationSettings)
{
    ui->setupUi(this);
    setWindowTitle("Enter Calibration Settings");


    //set default values
    high=7; ui->spinBox_height->setValue(high);
    wide=10;ui->spinBox_width->setValue(wide);
    squareSize=24.5;ui->plainTextEdit_squareSize->setPlainText(QString::number(squareSize));
    framesToGrab=25;ui->spinBox_framesToGrab->setValue(framesToGrab);
    delayBetween=5;ui->spinBox_delayBetween->setValue(delayBetween);

}

DialogCalibrationSettings::~DialogCalibrationSettings()
{
    delete ui;
}

void DialogCalibrationSettings::on_spinBox_framesToGrab_valueChanged(int arg1)
{
    framesToGrab=arg1;
}

void DialogCalibrationSettings::on_spinBox_width_valueChanged(int arg1)
{
    wide=arg1;
}

void DialogCalibrationSettings::on_spinBox_height_valueChanged(int arg1)
{
    high=arg1;
}

void DialogCalibrationSettings::on_plainTextEdit_squareSize_textChanged()
{
    if (float tmp=ui->plainTextEdit_squareSize->toPlainText().toFloat())
    {
        if (!squareSize==tmp) { //check to make sure it really changed otherwise it results in a race condition
            squareSize=tmp;
            ui->plainTextEdit_squareSize->setPlainText(QString::number(squareSize));
        }

    }

}

void DialogCalibrationSettings::on_spinBox_delayBetween_valueChanged(int arg1)
{
    delayBetween=arg1;
}
